
#include "Public.h"




void EXTIX_Init(void)
{

  NVIC_InitTypeDef NVIC_InitStructure;//定义结构体
  EXTI_InitTypeDef EXTI_InitStructure;//定义初始化结构体  
  
  

  RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOF,ENABLE );
  RCC_APB2PeriphClockCmd(RCC_APB2ENR_SYSCFGEN | RCC_APB2Periph_USART1 | RCC_AHBPeriph_GPIOA , ENABLE); // 使能外部中断时钟，功能复用IO时钟 

  

//=======  ----频率检测  中断配置   PA3

//清除中断标志位
EXTI_ClearITPendingBit(EXTI_Line3);
  
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource3);

EXTI_InitStructure.EXTI_Line = EXTI_Line3; //中断线的标号 取值范围为EXTI_Line0~EXTI_Line15 
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断模式，可选值为中断 EXTI_Mode_Interrupt 和事件 EXTI_Mode_Event。
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;//EXTI_Trigger_Rising;//触发方式，可以是下降沿触发 EXTI_Trigger_Falling，上升沿触发 EXTI_Trigger_Rising， 

EXTI_Init(&EXTI_InitStructure);//根据结构体信息进行初始化


//=============中断优先级配置


NVIC_InitStructure.NVIC_IRQChannel = EXTI2_3_IRQn; //使能外部中断所在的通道
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
NVIC_Init(&NVIC_InitStructure);


EXTI->IMR &=~0x08 ;  //关外部中断
EXTI_ClearITPendingBit(EXTI_Line3);   //清除 LINE 上的中断标志位




//=======  ----频率检测  中断配置  PF7

//清除中断标志位
EXTI_ClearITPendingBit(EXTI_Line7);
  
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOF, EXTI_PinSource7);

EXTI_InitStructure.EXTI_Line = EXTI_Line7; //中断线的标号 取值范围为EXTI_Line0~EXTI_Line15 
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断模式，可选值为中断 EXTI_Mode_Interrupt 和事件 EXTI_Mode_Event。
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;//EXTI_Trigger_Rising;//触发方式，可以是下降沿触发 EXTI_Trigger_Falling，上升沿触发 EXTI_Trigger_Rising， 

EXTI_Init(&EXTI_InitStructure);//根据结构体信息进行初始化


//=============中断优先级配置


NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn; //使能外部中断所在的通道
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
NVIC_Init(&NVIC_InitStructure);


EXTI->IMR &=~0x80 ;  //关外部中断
EXTI_ClearITPendingBit(EXTI_Line7);   //清除 LINE 上的中断标志位








}